package com.baize.markwondemo.spans;

import android.content.Context;
import android.graphics.Color;
import android.text.TextPaint;
import android.text.style.URLSpan;
import android.view.View;
import android.widget.Toast;

public class CustomMentionSpan extends URLSpan {
  private Context context;
  private String url; //channel jumpUrl
  private boolean clickable;

  public CustomMentionSpan(Context context, String url, boolean clickable) {
    super(url);
    this.context = context;
    this.url = url;
    this.clickable = clickable;
  }

  @Override
  public void onClick(View widget) {
//      LogUtil.d2(LOG_TAG, "[onClick] url=" + url);
    if (!clickable) return;
    Toast.makeText(context, "CustomMentionSpan click!", Toast.LENGTH_SHORT).show();
  }

  @Override
  public void updateDrawState(TextPaint ds) {
    super.updateDrawState(ds);
    ds.setUnderlineText(false);      //设置下划线
    ds.setColor(Color.parseColor("#5873F2"));       //设置链接颜色
  }
}